class proxyMine extends mine;

var float StickTime;
var float timeToArm;
var float tripTime;
var float ArmedCollisionRadius;
var float ArmedCollisionHeight;
var bool bArmed;

replication
{
    reliable if (Role==ROLE_Authority)
        bArmed;
}

simulated function PostNetBeginPlay()
{
	super.PostNetBeginPlay();
	bArmed=false;
}
/*
function ProcessTouch( actor Other, vector HitLocation )
{
    if ( Pawn(Other) != None && bArmed && (level.timeseconds - StickTime > timeToArm) && FastTrace(Hitlocation, Location))
    {
		noRepExplode(Location, Normal(HitLocation-Other.Location));
    }//else super.ProcessTouch(Other, HitLocation );
}  */

function tick(float dt){
    local pawn victims;
        tripTime+=dt;
        if(triptime > 0.2){
             triptime=0.0;
             foreach CollidingActors( class 'Pawn', Victims, ArmedCollisionRadius, Location )
	         {
		         if( Victims != none && bArmed && (level.timeseconds - StickTime > timeToArm) )
                 {
                     //SetTimer(0.5, false);
                    // if ( Level.NetMode != NM_DedicatedServer )
			         //   PlaySound(ImpactSound, SLOT_Misc );
                     //Disable('tick');
                     noRepExplode(Location, Normal(Victims.Location-Location));
		         }
	         }
        }
}

simulated function HitWall( vector HitNormal, actor Wall ){

    /*if (!bTimerSet)
    {
        SetTimer(ExplodeTimer, false);
        bTimerSet = true;
    }*/
    bArmed=true;
    StickTime = level.timeseconds;
    surfaceNormal = HitNormal;
    bBounce = False;
    SetPhysics(PHYS_None);
    SetBase(Wall);
    if(ROLE==ROLE_Authority){
        Enable('tick');
    }
    //SetCollisionSize(ArmedCollisionRadius, ArmedCollisionHeight);
    SetRotation(rotator(HitNormal));

	if ( (Level.NetMode != NM_DedicatedServer) && (Speed > 250) )
			PlaySound(ImpactSound, SLOT_Misc );
}

defaultproperties
{
     timeToArm=4.000000
     ArmedCollisionRadius=100.000000
     ArmedCollisionHeight=100.000000
     LifeSpan=0.000000
     Skins(0)=Texture'TFMedia.mine.proxyMineSkin'
     bcollideActors=true
}
